

import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gczn_hd/app/core/values/app_colors.dart';
import 'package:gczn_hd/app/core/values/app_values.dart';
import 'package:gczn_hd/app/core/widget/custom_title_bar.dart';

import '../../../../core/values/text_styles.dart';

class MachineMsg extends StatelessWidget{


  @override
  Widget build(BuildContext context) {
    final double imgSize = 174.h;

    return Column(
      children: [
        const CustomTitleBar(title: "设备信息"),
        Container(
          height: imgSize,
          margin: EdgeInsets.only(left: AppValues.size34.w, right: AppValues.size34.w, top: AppValues.size30.h, bottom: AppValues.size34.h),
          decoration: BoxDecoration(
            color: AppColors.textColorSecondary,
            borderRadius: BorderRadius.circular(AppValues.size12.r),
          ),
          child: Center(
            child: Text("图片"),
          ),
        ),
        _buildMessage(),
        _buildTotal(title: "5天未点检", value: "历史点检6次", color: AppColors.fialColor),
        _buildTotal(title: "2天未保养", value: "历史保养6次", color: AppColors.waitColor),
        _buildTotal(title: "0天未报修", value: "历史报修6次", color: AppColors.successColor),
      ],
    );
  }


  Widget _buildTotal({required String title, required String value, Color color = AppColors.successColor}){
    final Size boxSize = Size(172.w, 60.h);

    return Container(
      margin: EdgeInsets.only(top: AppValues.size20.h),
      child: Column(
        children: [
          Container(
            height: boxSize.height,
            decoration: BoxDecoration(
              border: Border.all(
                color: const Color.fromRGBO(39, 65, 80, 1),
                width: 1.0,
              ),
              borderRadius: BorderRadius.circular(AppValues.margin_12.r),
              color: AppColors.processBtn,//const Color.fromRGBO(12, 29, 46, 1),
            ),
            child: Row(
              children: [
                Container(
                  width: boxSize.width,
                  height: boxSize.height,
                  decoration: const BoxDecoration(
                    color:AppColors.totalBg
                  ),
                  child: Center(
                    child: Text(title, style: textStyle.copyWith(color: color),),
                  ),
                ),
                SizedBox(width: AppValues.size40.w,),
                Expanded(
                  child: Text(value, style: textStyle,),
                )
              ],
            ),
          )
        ],
      ),
    );
  }



  Widget _buildMessage(){
    List<Map<String, String>> list = [
      {"label": "设备名称", "value": "200T-01"},
      {"label": "设备分类", "value": "注塑机"},
      {"label": "所在位置", "value": "注塑1车间A08"},
      {"label": "点检标准", "value": "200T注塑机点检标准"},
      {"label": "点检频率", "value": "15天/次"},
      {"label": "上次点检", "value": "2024-2-28 19:42:51"},
    ];

    return Column(
      children: list.map((item) => _buildMessageItem(item)).toList(),
    );

  }

  Widget _buildMessageItem(Map<String, String> map){
    return Container(
      margin: EdgeInsets.only(bottom: AppValues.size20.h),
      child: Row(
        children: [
          SizedBox(
            width: AppValues.size108.w,
            child: Text(map["label"]!, style: textStyle20Opa8,),
          ),
          SizedBox(width: AppValues.size20.w,),
          Expanded(
            flex: 1,
            child: Text(map["value"]!, style: textStyle,),
          )
        ]
      )
    );
  }



}